<%@page language="java" isELIgnored="false" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<jsp:directive.include file="/WEB-INF/sitemesh-decorators/include.jsp"/>
<fmt:setBundle basename="bundles.thesis-resources"/>
<head>
<script type="text/javascript">
var tempStr2="";
$(function() {
	var studentList = '${students}';
	var studentStr = studentList.substring(studentList.indexOf('{')+1,studentList.indexOf('}'));
	studentStr = studentStr.replace(/=/g,":");
	var studentArr=studentStr.split(',');
	var tempArray = new Array();
	var tempStr="";
	for(var i=0;i<studentArr.length;i++){
		studentArr[i] = studentArr[i].replace(/\|/,",");
		tempStr = studentArr[i];
		tempStr = tempStr.substring(tempStr.indexOf(":")+1);
		tempArray[i]= tempStr;
	}
	$( "#studentText").autocomplete({
		source: tempArray,
		select: function(e, ui) {
			var cat = ui.item.value;
			getId(cat,studentArr,'student_studentId');
			
			$("#studentText").val(cat);
		},
		close: function(event, ui) {
			
			
		}
	});
	
	var categoryList2 = '${categories}';
	var catStr2 = categoryList2.substring(categoryList2.indexOf('{')+1,categoryList2.indexOf('}'));
	catStr2 = catStr2.replace(/=/g,":");
	//alert(catStr);
	var categoryArr2=catStr2.split(',');
	var tempArray2 = new Array();
	var tempStr2="";
	for(var i=0;i<categoryArr2.length;i++){
		categoryArr2[i] = categoryArr2[i];
		tempStr2 = categoryArr2[i];
		tempStr2 = tempStr2.substring(tempStr2.indexOf(":")+1);
		//alert(tempStr);
		tempArray2[i]= tempStr2;
	}
	var tempStr12="";
	
	$( "#categoryText").autocomplete({
		//source: categoryArr,
		source: tempArray2,
		//define select handler
		select: function(e, ui) {
			//create formatted data
			var cat = ui.item.value;
			getId(cat,categoryArr2,'categories_categoriesId');
			
			$("#categoryText").val(cat);
			//tempStr1 = cat.substring(cat.indexOf(":")+1);
			//alert(tempStr1);
			//tempStr2 = cat.substring(0,cat.indexOf(":"));
			//alert(tempStr2);
		},
		close: function(event, ui) {
			
			
		}
	});
	
	var categoryList3 = '${thesistoolss}';
	var catStr3 = categoryList3.substring(categoryList3.indexOf('{')+1,categoryList3.indexOf('}'));
	catStr3 = catStr3.replace(/=/g,":");
	//alert(catStr);
	var categoryArr3=catStr3.split(',');
	var tempArray3 = new Array();
	var tempStr3="";
	for(var i=0;i<categoryArr3.length;i++){
		categoryArr3[i] = categoryArr3[i];
		tempStr3 = categoryArr3[i];
		tempStr3 = tempStr3.substring(tempStr3.indexOf(":")+1);
		//alert(tempStr);
		tempArray3[i]= tempStr3;
	}
	var tempStr13="";
	
	$( "#thesistoolsText").autocomplete({
		//source: categoryArr,
		source: tempArray3,
		//define select handler
		select: function(e, ui) {
			//create formatted data
			var cat = ui.item.value;
			getId(cat,categoryArr3,'thesistools_thesistoolsid');
			
			$("#thesistoolsText").val(cat);
			//tempStr1 = cat.substring(cat.indexOf(":")+1);
			//alert(tempStr1);
			//tempStr2 = cat.substring(0,cat.indexOf(":"));
			//alert(tempStr3);
		},
		close: function(event, ui) {
			
			
		}
	});
	
	var categoryList4 = '${thesiscommitteess}';
	//var categoryList4 = '${facultyList}';
	var catStr4 = categoryList4.substring(categoryList4.indexOf('{')+1,categoryList4.indexOf('}'));
	catStr4 = catStr4.replace(/=/g,":");
	//alert(catStr);
	var categoryArr4=catStr4.split(',');
	var tempArray4 = new Array();
	var tempStr4="";
	for(var i=0;i<categoryArr4.length;i++){
		categoryArr4[i] = categoryArr4[i];
		tempStr4 = categoryArr4[i];
		tempStr4 = tempStr4.substring(tempStr4.indexOf(":")+1);
		//alert(tempStr);
		tempArray4[i]= tempStr4;
	}
	var tempStr14="";
	
	$( "#thesiscommitteesText").autocomplete({
		//source: categoryArr,
		source: tempArray4,
		//define select handler
		select: function(e, ui) {
			//create formatted data
			var cat = ui.item.value;
			getId(cat,categoryArr4,'thesiscommittees');
			
			$("#thesiscommitteesText").val(cat);
			//tempStr1 = cat.substring(cat.indexOf(":")+1);
			//alert(tempStr1);
			//tempStr2 = cat.substring(0,cat.indexOf(":"));
			//alert(tempStr4);
		},
		close: function(event, ui) {
			
			
		}
	});
	
	var categoryList5 = '${generatedproductss}';
	var catStr5 = categoryList5.substring(categoryList5.indexOf('{')+1,categoryList5.indexOf('}'));
	catStr5 = catStr5.replace(/=/g,":");
	//alert(catStr);
	var categoryArr5=catStr5.split(',');
	var tempArray5 = new Array();
	var tempStr5="";
	for(var i=0;i<categoryArr5.length;i++){
		categoryArr5[i] = categoryArr5[i];
		tempStr5 = categoryArr5[i];
		tempStr5 = tempStr5.substring(tempStr5.indexOf(":")+1);
		//alert(tempStr);
		tempArray5[i]= tempStr5;
	}
	var tempStr15="";
	
	$( "#generatedproductsText").autocomplete({
		//source: categoryArr,
		source: tempArray5,
		//define select handler
		select: function(e, ui) {
			//create formatted data
			var cat = ui.item.value;
			getId(cat,categoryArr5,'generatedproducts');
			
			$("#generatedproductsText").val(cat);
			//tempStr1 = cat.substring(cat.indexOf(":")+1);
			//alert(tempStr1);
			//tempStr2 = cat.substring(0,cat.indexOf(":"));
			//alert(tempStr5);
		},
		close: function(event, ui) {
			
			
		}
	});
});
//if(tempStr2=="")
//	$("#category_categoryId").val(tempStr2);
	
function getId(str,arr,imp){
	var key = "";
	var value ="";
	var tempStr="";
	for(var i=0;i<arr.length;i++){
		tempStr = arr[i];
		tempStr = tempStr.replace(/^\s+|\s+$/g,'');
		key=tempStr.substring(0,tempStr.indexOf(":"));
		value = tempStr.substring(tempStr.indexOf(":")+1);
		if(value==str){
			//alert(key);
			$("#"+imp).val(key);
		}
	}
}

$().ready(function() {
	$('#facultyresearchform').validate();
});
</script>
</head>
<body>
<form:form id="facultyresearchform" action="submitAdvancedSearchThesis" modelAttribute="thesis" name = "Mainform">
  <div >
  <br/><br/>
            <div class="Faculty">
            	<div>By Student Name</div> 
            	<div class="value">
            		<input type="text" id="studentText" />
            		<form:hidden path="student" id="student_studentId"/>&nbsp;&nbsp;&nbsp;&nbsp;(Example: John Smith)
            	</div><div>&nbsp;</div>
                <div><div class="label">By Title</div><div class="value"><form:input path="title" type="text"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Example: Comparison of testing methodologies)</div></div><div>&nbsp;</div>
            <%--    <div><div class="label">By Abstract</div><div class="value"><form:input path="abstract_" type="text"/></div></div><div>&nbsp;</div>--%> 
                <div>
                	<div class="label">By Start Date</div>
                	<div class="value"><input type="text" name="startDate" class="date" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Example: 05/15/2012)</div><div>&nbsp;</div>
                </div>
                <div>
                	<div class="label">By End Date</div>
                	<div class="value"><input name="endDate" class="date"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Example: 05/15/2012)</div><div>&nbsp;</div>
                </div>
                <div>
	                <div class="label">By Category</div>
	                <div class="value">
	                	<input id="categoryText" type="text"/>
	                	<form:hidden path="categories" id="categories_categoriesId"/>&nbsp;&nbsp;&nbsp;&nbsp;(Example: Databases)
	                </div>
                </div><div>&nbsp;</div>
                <div>
                	<div class="label">By Tool Used</div>
                	<div class="value">
                		<input id="thesistoolsText" type="text"/>
                		<form:hidden path="thesistools" id="thesistools_thesistoolsid"/>&nbsp;&nbsp;&nbsp;&nbsp;(Example: Visual Studio 2010)
                	</div>
                </div><div>&nbsp;</div>
                <div>
                	<div class="label">By Thesis Chair Name</div>
                	<div class="value">
                		<input id="thesiscommitteesText" type="text"/>
                		<form:hidden path="thesiscommittees"/>&nbsp;&nbsp;&nbsp;&nbsp;(Example: Asai Asaithambi)
                	</div>
                </div><div>&nbsp;</div>
                <div>
                	<div class="label">By Generated Product</div>
                	<div class="value">
                		<input id="generatedproductsText" type="text"/>
                		<form:hidden path="generatedproducts"/>&nbsp;&nbsp;&nbsp;&nbsp;(Example: JIT Compiler for Java)
                	</div>
                </div><div>&nbsp;</div>
                <div><div class="label">Check for only Completed Theses</div><div class="checkbox"><form:checkbox path="thesisstatuses" value="thesisstatusid"/></div></div><div>&nbsp;</div>
                <div id="submitFaculty">
					<button id="submitButton">Submit</button>
        		</div>
            </div>
        </div>
    </form:form>
    </body>